﻿using Common;
using Domain.Common;
using Domain.Map;
using Microsoft.Xna.Framework;

namespace UIComponentSprite.Grid
{
    /// <summary>
    /// 地图网格
    /// </summary>
    public class MapGridController:UserControlledSprite
    {
        private GridUnitSprite _gridUnitSprite = new GridUnitSprite();
        public MapGridController()
        {
            _gridUnitSprite.SetShowing(true);
            _gridUnitSprite.WillDisplayType = GridTypeEnum.Wangge;
        }
        public override void Draw(GameTime gameTime)
        {
            if (!Showing)
                return;
            foreach (var mapUnit in MapUnit.GetDisplayMapUnits())
            {
                if (mapUnit.TerrainType != "0" && mapUnit.TerrainType != "4" && mapUnit.TerrainType != "7")
                {
                    _gridUnitSprite.DrawPosition = mapUnit.DrawPosition;
                    _gridUnitSprite.Draw(gameTime);
                } 
            }
        }

        public override void Update(GameTime gameTime)
        {
            if (!Showing)
                return;
           _gridUnitSprite.Update(gameTime);
        }

       
    }
}
